package com.ruoyi.cinema.event.handler;

import com.ruoyi.cinema.BO.GoodsBuyedMsgBo;
import com.ruoyi.cinema.event.GoodsBuyEvent;
import com.ruoyi.cinema.service.impl.CustomerServiceImpl;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class GoodsBuyEventHandler {

    private final CustomerServiceImpl customerService;

    public GoodsBuyEventHandler(CustomerServiceImpl customerService) {
        this.customerService = customerService;
    }

    @EventListener
    @Async("threadPoolTaskExecutor")
    public void handleBuyEvent(GoodsBuyEvent event){

        customerService.sendGoodsBuyMessage((GoodsBuyedMsgBo) event.getSource());
    }
}
